import http from '@/utils/http.js'
const module = {
    namespaced: true,//开启命名空间
    state: {
        cinemaList: [],
        copyCinemaList: [] // 备份
    },
    mutations: {
        setCinemaData(state, data) {
            state.cinemaList = data
            state.copyCinemaList = data
        },
        districtChange(state, data) {
            if (data === '全城') {
                state.cinemaList = state.copyCinemaList
            } else {
                state.cinemaList = state.copyCinemaList.filter(item => item.district.name === data)
            }

        }
    },
    actions: {
        getCinemaData(store, id) {
            return http({
                url: "/gateway?cityId=" + id + "&ticketFlag=1&k=4313181",
                headers: {
                    "X-Host": "mall.film-ticket.cinema.list",
                },
            }).then(res => {
                store.commit('setCinemaData', res.data.data.cinemas)
            })
        }
    }
}

export default module